In [1]:
import pandas as pd
import plotly.express as px
#import plotly.graph_objects as go

import dash
from dash import dcc
from dash import html
from dash.dependencies import Input, Output, State
# -----------------------------------------------------------
df = pd.read_csv("Dashboard.csv", encoding='windows-1252')
df.head()
Out[1]:
Customer ID Segment Category Sales Quantity Discount Profit
0 CG-12520 Consumer Furniture 261.9600 2 0.00 41.91
1 CG-12520 Consumer Furniture 731.9400 3 0.00 219.58
2 DV-13045 Corporate Office Supplies 14.6200 2 0.00 6.87
3 SO-20335 Consumer Furniture 957.5775 5 0.45 -383.03
4 SO-20335 Consumer Office Supplies 22.3680 2 0.20 2.52
In [2]:
df1 = pd.DataFrame(df.groupby(["Customer ID"])[["Discount"]].sum())
df1
Out[2]:
Discount
Customer ID
-19675 0.1
-19750 0.0
AA-10315 1.0
AA-10375 1.2
AA-10480 0.2
... ...
XP-21865 1.3
YC-21895 0.6
YS-21880 0.6
ZC-21910 7.9
ZD-21925 1.0

792 rows × 1 columns

In [3]:
px.bar(data_frame=df1, x=df1.index, y="Discount", width=2000, title="Discount per Customer")
In [4]:
df2 = df.groupby(["Segment"])[["Discount"]].sum()
df2
Out[4]:
Discount
Segment
Consumer 820.51
Corporate 477.85
Home Office 261.93
In [5]:
px.bar(data_frame=df2, x=df2.index, y="Discount", width=600, title="Discounts per Segment")
In [6]:
df3 = df.groupby(["Category"])[["Discount"]].sum()
df3
Out[6]:
Discount
Category
Furniture 368.89
Office Supplies 947.60
Technology 243.80
In [7]:
px.bar(data_frame=df3, x=df3.index, y="Discount", width=600, title="Discounts per Category")
In [8]:
df4 = df.groupby(["Quantity"])[["Discount"]].sum()
df4
Out[8]:
Discount
Quantity
1 137.51
2 371.77
3 368.97
4 187.83
5 193.29
6 95.07
7 98.16
8 44.10
9 38.17
10 10.87
11 3.30
12 2.60
13 4.25
14 4.40
In [9]:
px.bar(data_frame=df4, x=df4.index, y="Discount", width=600, title="Discounts per Quantity")
In [10]:
# -----------------------------------------------------------

# external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
# app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
In [11]:
# -----------------------------------------------------------

# app.layout = html.Div([
#                         html.H1("Dashboard", style={"textAlign":"center"}),
#                         html.Hr(),
#                       ])

# if __name__ == '__main__':
#     app.run_server(debug=False)